﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;
using BYRBBS.Model;

namespace BYRForum.Binding.Thread
{
    public class ThreadsList
    {
        public ThreadsList()
        {
            this.Items = new ObservableCollection<ThreadsItem>();
        }
        public ObservableCollection<ThreadsItem> Items { get; private set; }

        public void LoadData(ArticleInfo[] alist)
        {
            Items.Clear();
            for (int i = 0; i < alist.Length; i++)
            {
                this.Items.Add(new ThreadsItem()
                {
                    GroupID = alist[i].Group_id,
                    Title = alist[i].Title,
                    BoardName = alist[i].Board_name,
                    ShowBoardName="From : " + alist[i].Board_name
                });
            }
        }

        public void LoadData(ArticleHead[] alist)
        {
            Items.Clear();
            for (int i = 0; i < alist.Length; i++)
            {
                this.Items.Add(new ThreadsItem()
                {
                    GroupID = alist[i].Group_id,
                    Title = alist[i].Title,
                    UserName="发帖人 : " + alist[i].author.Id,
                    BoardName = alist[i].Board_name,
                    LastReplyTime=alist[i].Last_reply_time
                });
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
